package com.gsnd.gsnd22estore.service.impl;


import com.gsnd.gsnd22estore.domain.EsAddress;
import com.gsnd.gsnd22estore.mapper.EsAddressMapper;
import com.gsnd.gsnd22estore.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    EsAddressMapper esAddressMapper;



    @Override
    public List<EsAddress> getAllAddressByUserId(Integer userId) {
        return esAddressMapper.selectByUserId(userId);
    }

    @Override
    public void createAddress(EsAddress address) {
        esAddressMapper.insert(address);
    }

    @Override
    public void removeAddressById(Integer id) {
        esAddressMapper.delete(id);
    }

    @Override
    public void editAddressInfo(EsAddress address) {
        esAddressMapper.update(address);
    }

    @Override
    public void changeDefaultAddress(Integer addressId, Integer userId) {
        esAddressMapper.updateDefault(addressId,userId);
    }

}
